package cn.edu.zafu.bigdata.psy;

import java.util.HashMap;
import java.util.Map;

class StudentGradeManager {
    private Map<String, Integer> studentGrades = new HashMap<>();

    public void addStudent(String name, int grade) {
        studentGrades.put(name, grade);
    }

    public int getGrade(String name) {
        Integer grade = studentGrades.get(name);
        return grade!= null? grade : -1;
    }

    public void removeStudent(String name) {
        studentGrades.remove(name);
    }
}

public class Test3_2 {
    public static void main(String[] args) {
        StudentGradeManager manager = new StudentGradeManager();
        manager.addStudent("张三", 90);
        manager.addStudent("李四", 85);
        manager.addStudent("王五", 95);

        int gradeOfZhangSan = manager.getGrade("张三");
        if (gradeOfZhangSan!= -1) {
            System.out.println("张三的成绩是：" + gradeOfZhangSan);
        }

        manager.removeStudent("李四");

        int gradeOfLiSi = manager.getGrade("李四");
        if (gradeOfLiSi == -1) {
            System.out.println("李四已被删除，查询李四成绩返回 -1。");
        }
    }
}
